﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;

namespace CommonConfig
{
    public class DwTool
    {
        public static void BindProperty(object obj, DataRow dataRow)
        {
            Type type = obj.GetType();
            PropertyInfo[] propertyCollection = type.GetProperties();
            foreach (PropertyInfo propertyInfo in propertyCollection)
            {
                string propertyName = propertyInfo.Name;
                
                if (dataRow.Table.Columns.Contains(propertyName))
                {
                    propertyInfo.SetValue(obj, dataRow[propertyInfo.Name], null);
                }
            }
        }
    }
}
